<extend name="Public/base" />
<block name="title1">主页</block>
<block name="css"></block>
<block name="main1"><div style="width:1000px;height:340px">
<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	
</head>
<body>

<div id="content" style="border:1px solid red;height:400px;overflow:auto;">

</div>

<div id="uid"><{$uid}></div>
	
<input type="text" name="content"> 

	<div id="resid">admin</div>
	
<input type="text" value="0" name="count">

<input type="button" name="load" value="load">

<input type="submit" name="send" value="发送">

<script>

$('[name="load"]').click(function(){
	
   
	var count = $('[name="count"]').val();
	$.get('<{:U("query")}>',{count:count},function(data){
           
		$('[name="count"]').val(data.count);
		if(data.success){
			$('[name="load"]').click();
				var html = ''; 
			$(data.rows).map(function(k,v){
				html += '<span><p style="float:right">'+v.content+'</p></span>'
			});

			$('#content').append(html);
		}else{
			$('[name="load"]').click();
		}		

	},'json');

});

$('[name="load"]').click();

$('[name="send"]').click(function(){
	var content = $('[name="content"]').val();
	var uid = $('#uid').text();
	var resid = $('#resid').text();

  
	$('[name="content"]').val('');

	$.post('<{:U("add")}>',{content:content,uid:uid,resid:resid},function(data){
	  var html = ''; 
                 html += '<p>'+data.content+'</p>';
			$('#content').append(html);
	  
	},'json');

});










</script>
	
</body>
</html>
</block>